<template>
  <div>
    <TopFilter
      :list="topFilterList"
      :cols="3"
      @filterChange="changeHandle"
    ></TopFilter>

    <FilterTable
      ref="table"
      :columns="columns"
      columnsRef="testindex"
      selectionType="single"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>

    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <el-button @click="closeDrawer(2)" type="primary">确 定</el-button>
    </div>
  </div>
</template>

<script>
import { getPartOrder } from '@/api/partsmanage/claim/apply';
export default {
  data(){
    return{
      topFilterList: this.createdFrom(),
      fetchParams: {},
      columns:this.createdTable(),
      fetchApi: getPartOrder,
      selectList: []
    }
  },
  mounted() {
    // 分页
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods:{
    createdFrom(){
      return [
        {
          type: 'INPUT',
          label: '采购订单号',
          fieldName: 'xsddhm',
          placeholder: '请输入',
        },
      ]
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '订单号',
          dataIndex: 'xsddhm',
          sorter: true,
        },
        {
          title: '经销商代码',
          dataIndex: 'dealer_code',
          sorter: true,
        },
        {
          title: '经销商名称',
          dataIndex: 'dealer_name',
          sorter: true,
        },
      ]
    },
    changeHandle(val){
      this.fetchParams=Object.assign({},this.fetchParams,val)
    },
    closeDrawer(type){
      if(type==1){
        this.$emit('close')
      }else{
        if (this.selectList !== null && this.selectList !== [] && this.selectList !== undefined && this.selectList.length > 0) {
          let arr=this.selectList;
          this.$emit('selectedFun',arr)
        } else {
          this.$notify.error({ title: '提示信息', message: '请选择一条数据' || '操作失败!' });
        }
      }
    },
    selectChangeHandle(val){
      this.selectList=val;
    }
  }
}
</script>